package com.nhim.cms.domain;

import static javax.persistence.GenerationType.IDENTITY;

import java.sql.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Version;

/**
 * ContentVersion entity. @author Huy Lieu Ta
 */
@Entity
@Table(name = "nhim_content_version", catalog = "nhim_cms")
public class ContentVersion implements java.io.Serializable{
	
	
	private static final long serialVersionUID = 1L;
	
	private Integer id;
	private Date finalizedDate;
	private Date checkOutDate;
	private Date deactivateDate;
	private Date createDate;
	private Integer version;
	private Boolean isLive;
	private Content content;
	private Content parent;
	private ContentType contentType;
	private Template template;
	private String name;
	private String path;
	private Set<ContentVersionValue> contentVersionValues = new HashSet<ContentVersionValue>(0);
	/**
	 * @param id the id to set
	 */
	public void setId(Integer id) {
		this.id = id;
	}
	/**
	 * @return the id
	 */
	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "id", unique = true, nullable = false)
	public Integer getId() {
		return id;
	}
	/**
	 * @param finalizedDate the finalizedDate to set
	 */
	public void setFinalizedDate(Date finalizedDate) {
		this.finalizedDate = finalizedDate;
	}
	/**
	 * @return the finalizedDate
	 */
	@Column(name = "finalized_date")
	public Date getFinalizedDate() {
		return finalizedDate;
	}
	/**
	 * @param checkOutDate the checkOutDate to set
	 */
	public void setCheckOutDate(Date checkOutDate) {
		this.checkOutDate = checkOutDate;
	}
	/**
	 * @return the checkOutDate
	 */
	@Column(name = "checkout_date")
	public Date getCheckOutDate() {
		return checkOutDate;
	}
	/**
	 * @param deactivateDate the deactivateDate to set
	 */
	public void setDeactivateDate(Date deactivateDate) {
		this.deactivateDate = deactivateDate;
	}
	/**
	 * @return the deactivateDate
	 */
	@Column(name = "deactivate_date")
	public Date getDeactivateDate() {
		return deactivateDate;
	}
	/**
	 * @param createDate the createDate to set
	 */
	public void setCreateDate(Date createDate) {
		this.createDate = createDate;
	}
	/**
	 * @return the createDate
	 */
	@Column(name = "create_date",nullable = false)
	public Date getCreateDate() {
		return createDate;
	}
	/**
	 * @param version the version to set
	 */
	public void setVersion(Integer version) {
		this.version = version;
	}
	/**
	 * @return the version
	 */
	@Version
	@Column(name = "version")
	public Integer getVersion() {
		return version;
	}
	/**
	 * @param isLive the isLive to set
	 */
	public void setIsLive(Boolean isLive) {
		this.isLive = isLive;
	}
	/**
	 * @return the isLive
	 */
	@Column(name = "is_live",nullable = false)
	public Boolean getIsLive() {
		return isLive;
	}
	/**
	 * @param content the content to set
	 */
	public void setContent(Content content) {
		this.content = content;
	}
	/**
	 * @return the content
	 */
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "content_id", nullable = false)
	public Content getContent() {
		return content;
	}
	/**
	 * @param parent the parent to set
	 */
	public void setParent(Content parent) {
		this.parent = parent;
	}
	/**
	 * @return the parent
	 */
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "parent_id", nullable = true)
	public Content getParent() {
		return parent;
	}
	/**
	 * @param name the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}
	/**
	 * @return the name
	 */
	@Column(name = "name")
	public String getName() {
		return name;
	}
	/**
	 * @param path the path to set
	 */
	public void setPath(String path) {
		this.path = path;
	}
	/**
	 * @return the path
	 */
	@Column(name = "path")
	public String getPath() {
		return path;
	}
	/**
	 * @param contentType the contentType to set
	 */
	public void setContentType(ContentType contentType) {
		this.contentType = contentType;
	}
	/**
	 * @return the contentType
	 */
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "content_type_id", nullable = false)
	public ContentType getContentType() {
		return contentType;
	}
	/**
	 * @param template the template to set
	 */	
	public void setTemplate(Template template) {
		this.template = template;
	}
	/**
	 * @return the template
	 */
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "template_id", nullable = false)
	public Template getTemplate() {
		return template;
	}
	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "contentVersion")
	public Set<ContentVersionValue> getContentVersionValues() {
		return this.contentVersionValues;
	}
	public void setContentVersionValues(Set<ContentVersionValue> values)
	{
		this.contentVersionValues = values;
	}

	

}
